<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<!-- remove old header -->


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>cogen API Reference Documentation
        - Module: wsgi</title><meta name="MSSmartTagsPreventParsing" content="true" /><meta http-equiv="imagetoolbar" content="no" /><link href="css/default.css" rel="stylesheet" type="text/css" /><link href="css/pygments.css" rel="stylesheet" type="text/css" />
    <!-- <link rel="shortcut icon" href="/images/favicon.ico" type="image/vnd.microsoft.icon"/> -->
    <link rel="stylesheet" href="css/apydia.css" type="text/css" />
    <script src="js/jquery-1.2.1.pack.js" type="text/javascript"></script>
    <script src="js/apydia.js" type="text/javascript"></script>
	<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
</head>
<body>
    <div id="page">
        <div id="browser">
            <div class="browser-section">
                <h2>Module Index</h2>
                <ul>
                    <li>
                        <a href="cogen.html">cogen</a>
                    </li><li>
                        <a href="cogen.common.html">cogen.common</a>
                    </li><li>
                        <a href="cogen.core.html">cogen.core</a>
                    </li><li>
                        <a href="cogen.core.coroutine.html">cogen.core.coroutine</a>
                    </li><li>
                        <a href="cogen.core.events.html">cogen.core.events</a>
                    </li><li>
                        <a href="cogen.core.queue.html">cogen.core.queue</a>
                    </li><li>
                        <a href="cogen.core.reactors.html">cogen.core.reactors</a>
                    </li><li>
                        <a href="cogen.core.schedulers.html">cogen.core.schedulers</a>
                    </li><li>
                        <a href="cogen.core.sockets.html">cogen.core.sockets</a>
                    </li><li>
                        <a href="cogen.core.util.html">cogen.core.util</a>
                    </li><li>
                        <a href="cogen.web.html">cogen.web</a>
                    </li><li>
                        <a href="cogen.web.async.html">cogen.web.async</a>
                    </li><li class="active">
                        <a href="cogen.web.wsgi.html">cogen.web.wsgi</a>
                    </li>
                </ul>
            </div>
            <div class="browser-section">
                <h2>Classes</h2>
                <ul>
                    <li>
                        <a href="cogen.web.wsgi.WSGIServer.WSGIConnection.html">WSGIConnection</a>
                    </li><li>
                        <a href="cogen.web.wsgi.WSGIFileWrapper.html">WSGIFileWrapper</a>
                    </li><li>
                        <a href="cogen.web.wsgi.WSGIServer.html">WSGIServer</a>
                    </li>
                </ul>
            </div>
        </div>
        <div id="content">
    <h1>Module:
        cogen.web.wsgi
    </h1>
    <div class="docstring plain">This wsgi server is a single threaded, single process server that interleaves
the iterations of the wsgi apps - I could add a threadpool for blocking apps in
the future.<br /><br />If you don't return iterators from apps and return lists you'll get, at most,
the performance of a server that processes requests sequentialy.<br /><br />On the other hand this server has coroutine extensions that suppose to support
use of middleware in your application. <br /><br />Example app with coroutine extensions:<br /><br /><pre class="codeblock python python python python python python python python python python python python python python python python python python python python python python python python python" name="code">
def wait_app(environ, start_response):
  start_response('200 OK', [('Content-type','text/html')])
  yield "I'm waiting for some signal"
  yield environ['cogen'].core.events.WaitForSignal("abc", timeout=1)
  if isinstance(environ['cogen'].result, Exception):
    yield "Your time is up !"
  else:
    yield "Someone signaled me: %s" % environ['cogen'].result
</pre><ul><li> <code name="code" class="python">environ['cogen'].core</code> is actualy a wrapper that sets </li></ul><blockquote><code name="code" class="python">environ['cogen'].operation</code> with the called object and returns a empty string. This should penetrate most of the middleware - according to the wsgi spec, middleware should pass a empty string if it doesn't have anything to return on that specific iteration point, or, in other words, the length of theapp iter returned by middleware should be at least that of the app.</blockquote><ul><li> the wsigi server will set <code name="code" class="python">environ['cogen'].result</code> with the result of the </li></ul><blockquote>operation and <code name="code" class="python">environ['cogen'].exception</code> with the details of the exception - if any: <code name="code" class="python">(exc_type, exc_value, traceback_object)</code>.</blockquote>
HTTP handling code taken from the CherryPy WSGI server.</div>
    <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\web\wsgi.py#L1">View source</a>
    </li>
</ul>
    <div>
        <h2>Classes</h2>
            <h3>
                <a href="cogen.web.wsgi.WSGIServer.WSGIConnection.html">WSGIConnection</a>
            </h3>
            <div class="docstring plain"></div>
            <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li>
        <a href="cogen.web.wsgi.WSGIServer.WSGIConnection.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\web\wsgi.py#L145">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.web.wsgi.WSGIFileWrapper.html">WSGIFileWrapper</a>
            </h3>
            <div class="docstring plain"></div>
            <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li>
        <a href="cogen.web.wsgi.WSGIFileWrapper.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\web\wsgi.py#L86">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.web.wsgi.WSGIServer.html">WSGIServer</a>
            </h3>
            <div class="docstring plain">An HTTP server for WSGI.
<table><tr><td style="border: 1px solid #aaa; padding: 5px;"> Option </td><td style="border: 1px solid #aaa; padding: 5px;"> Description </td></tr><tr><td style="border: 1px solid #aaa; padding: 5px;"> bind_addr </td><td style="border: 1px solid #aaa; padding: 5px;"> The interface on which to listen for connections. For TCP sockets, a (host, port) tuple. Host values may be any IPv4 or IPv6 address, or any valid hostname. The string 'localhost' is a synonym for '127.0.0.1' (or '::1', if your hosts file prefers IPv6). The string '0.0.0.0' is a special IPv4 entry meaning "any active interface" (INADDR_ANY), and '::' is the similar IN6ADDR_ANY for IPv6. The empty string or None are not allowed.  For UNIX sockets, supply the filename as a string. </td></tr><tr><td style="border: 1px solid #aaa; padding: 5px;"> wsgi_app </td><td style="border: 1px solid #aaa; padding: 5px;"> the WSGI 'application callable'; multiple WSGI applications may be passed as (path_prefix, app) pairs. </td></tr><tr><td style="border: 1px solid #aaa; padding: 5px;"> server_name </td><td style="border: 1px solid #aaa; padding: 5px;"> the string to set for WSGI's SERVER_NAME environ entry. Defaults to socket.gethostname(). </td></tr><tr><td style="border: 1px solid #aaa; padding: 5px;"> request_queue_size </td><td style="border: 1px solid #aaa; padding: 5px;"> the 'backlog' argument to socket.listen() specifies the maximum number of queued connections (default 5). </td></tr><tr><td style="border: 1px solid #aaa; padding: 5px;"> protocol </td><td style="border: 1px solid #aaa; padding: 5px;"> the version string to write in the Status-Line of all HTTP responses. For example, "HTTP/1.1" (the default). This also limits the supported features used in the response. </td></tr></table></div>
            <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li>
        <a href="cogen.web.wsgi.WSGIServer.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\web\wsgi.py#L508">View source</a>
    </li>
</ul>
    </div>
        </div>
        <div id="footer">
            Generated with <a href="http://apydia.ematia.de/" class="extern">
            Apydia 0.0.3</a>
        </div>
    </div>
</body>
</html>